coreVersion: v1
kind: Item
includeTemplates:
  - default
  - versioned
  - localized
metadata:
  name: part
  displayName: Part
  pluralName: parts
  displayPluralName: Parts
  dataSource: main
  tableName: design_parts
  titleAttribute: name
  description: Parts
  icon: TagOutlined
  core: false
  performDdl: true
#  versioned: true
#  manualVersioning: false
#  # revisionPolicy: 48fea283-2872-4ca3-8fbd-980b7654907b
#  localized: true
  notLockable: false
  implementation: ru.scisolutions.customimpl.item.PartItemImpl
spec:
  attributes:
    labelGroup:
      type: relation
      relType: manyToOne
      target: partLabelGroup
      columnName: label_group_id
      displayName: Label Group
      description: Label Group
      required: true
      colWidth: 180
    label:
      type: string
      columnName: label
      displayName: Label
      description: Label
      length: 50
      required: true
      unique: true
      colWidth: 200
    isReserved:
      type: bool
      columnName: is_reserved
      displayName: Reserved
      description: Reserved flag
      colWidth: 160
    name:
      type: string
      columnName: name
      displayName: Name
      description: Name
      length: 300
      required: true
      colWidth: 300
    description:
      type: string
      columnName: description
      displayName: Description
      description: Description
      length: 300
      colWidth: 300
    product:
      type: relation
      relType: manyToOne
      target: product
      inversedBy: parts
      columnName: product_id
      displayName: Product
      description: Product
      required: true
#    partType:
#      type: enum
#      columnName: part_type
#      enumSet:
#        - Сборка
#        - Компонент
#        - Материал
#        - Программа
#      displayName: Part Type
#      description: Part Type
    partType:
      type: relation
      relType: manyToOne
      target: partType
      columnName: part_type_id
      displayName: Part Type
      description: Part Type
#      required: true
    ownershipType:
      type: enum
      columnName: ownership_type
      enumSet:
        - Разработанное
        - Заимствованное
        - Покупное
      displayName: Ownership Type
      description: Ownership Type
#    units:
#      type: enum
#      enumSet:
#        - Кг
#        - Шт
#      columnName: units
#      displayName: Units
#      description: Units
    releaseDate:
      type: datetime
      columnName: release_date
      displayName: Release Date
      description: Release Date
      colWidth: 180
    effectiveDate:
      type: datetime
      columnName: effective_date
      displayName: Effective Date
      description: Effective Date
      colWidth: 180
    ownedBy:
      type: relation
      relType: manyToOne
      target: department
      columnName: owned_by_id
      displayName: Owned By
      description: Owned By
      colWidth: 180
    startSheet:
      type: relation
      relType: manyToOne
      target: startSheet
      inversedBy: parts
      columnName: start_sheet_id
      displayName: Start Sheet
      description: Start Sheet
    partBOM:
      type: relation
      relType: oneToMany
      target: partBOM
      mappedBy: source
      displayName: Part BOM
      description: Part BOM
    claims:
      type: relation
      relType: manyToMany
      target: labelClaim
      intermediate: partLabelClaimMap
      inversedBy: parts
      displayName: Label Claims
      description: Label Claims
    documents:
      type: relation
      relType: oneToMany
      target: document
      mappedBy: part
      displayName: Documents
      description: Documents
    changeNotices:
      type: relation
      relType: manyToMany
      target: changeNotice
      intermediate: partChange
      inversedBy: parts
      displayName: Change Notices
      description: Change Notices